#include <stdio.h>
#include <math.h>
int narcissistic( int number );
void PrintN( int m, int n );

int main()
{
    int m, n;

    scanf("%d %d", &m, &n);
    if ( narcissistic(m) ) printf("%d is a narcissistic number\n", m);
    PrintN(m, n);
    if ( narcissistic(n) ) printf("%d is a narcissistic number\n", n);

    return 0;
}
int narcissistic( int number )
{
    int count=0,u=0,sum=0,n;
    n=number;
    while(n!=0){
        number=number/10;
        count++;
    }
    n=number;
   while(n!=0){
        u=n%10;
        sum=sum+pow(u,count);
        n=n/10;
    }
    if(number==sum) 
        return 1;
    else    
        return 0;

}
void PrintN( int m, int n )
{
    int i;
    for(i=m+1;i<=n;i++)
    {
        if(narcissistic(i)==1)
            printf("%d\n",i);
    }
}
